package net.hn.hnms.biz.emgcy.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.emgcy.domain.DrillBasicInformationPo;
import net.hn.hnms.biz.emgcy.domain.dto.DrillBasicInformationDto;
import net.hn.hnms.biz.emgcy.domain.vo.DrillBasicInformationVo;
import net.hn.hnms.biz.emgcy.service.DrillBasicInformationService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: baijiajun
 * @Date: 2022/9/15
 */
@Api(value = "应急演练模块", tags = {"应急演练"})
@RestController
@RequestMapping("drillBasicInformation")
public class DrillBasicInformationController {
    @Resource
    private DrillBasicInformationService drillBasicInformationService;

    @ApiOperation("获取演练信息列表")
    @GetMapping("pageList")
    @AutoSetMineCode
    public R<ResponsePage<DrillBasicInformationVo>> pageList(PageQuery pageQuery, DrillBasicInformationDto drillBasicInformationDto) {
        ResponsePage<DrillBasicInformationVo> list= drillBasicInformationService.pageList(pageQuery,drillBasicInformationDto);
        return R.ok(list);
    }

    @ApiOperation("演练信息添加")
    @PostMapping("/add")
    public R add(@RequestBody DrillBasicInformationPo drillBasicInformationPo){
        Boolean flag = drillBasicInformationService.add(drillBasicInformationPo);
        if(flag){
            return R.ok("新增成功");
        }
        return R.fail("新增失败");
    }

    @ApiOperation("演练信息修改")
    @PutMapping("/update")
    public R update(@RequestBody DrillBasicInformationPo drillBasicInformationPo){
        Boolean flag = drillBasicInformationService.update(drillBasicInformationPo);
        if(flag){
            return R.ok("修改成功");
        }
        return R.fail("修改失败");
    }
    @ApiOperation("演练信息删除")
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable Long id){
        Boolean flag = drillBasicInformationService.delete(id);
        if(flag){
            return R.ok("删除成功");
        }
        return R.fail("删除失败");
    }
}
